package cn.MaySoon.shenfu;

import com.germ.germplugin.api.GermPacketAPI;
import com.germ.germplugin.api.GermSrcManager;
import com.germ.germplugin.api.dynamic.gui.GermGuiScreen;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.serverct.ersha.attribute.data.AttributeSource;

import java.io.File;
import java.util.HashMap;

public class main extends JavaPlugin {
    public static HashMap<Player,shenfu> PlayerShenFuData = new HashMap<Player, shenfu>();
    public static HashMap<Player, AttributeSource> PlayerAttribute = new HashMap<Player,AttributeSource>();
    public static HashMap<Player,Integer> PlayerJiNengZhanLi = new HashMap<>();
    public static main plugin;
    static File filess;
    static FileConfiguration config;
    public Economy economy = null;
    public boolean isEco = false;

    public void onEnable(){
                Bukkit.getServer().getPluginManager().registerEvents(new listen(),this);
                plugin = this;
        config = getConfig();
        filess = new File(getDataFolder(), "config.yml");
        this.isEco = onEconomy();
        saveDefaultConfig();
        saveResource("shenfu.yml",false);
    }

    public boolean onEconomy()
    {

        RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
        if ((economyProvider != null) && ((this.economy = (Economy)economyProvider.getProvider()) == null)) {
            this.isEco = true;
        }
        return !this.isEco;
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (label.equalsIgnoreCase("shenfu")) {

            Player p = (Player) sender;
            if (cn.MaySoon.PlayerLevel.main.PlayerLevel.get(p).getLevel()<150){
                p.sendMessage("§c神符功能150级开放");
                return true;
            }
            else{
                Germ.shenfugerm((Player) sender).openGui((Player) sender);
                return true;
            }

        }
        return true;
    }

}
